{
    "cells": [
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "%env OPENAI_API_KEY=sk-************"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 2,
            "metadata": {},
            "outputs": [],
            "source": [
                "from llama_index import MboxReader, GPTSimpleVectorIndex"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "documents = MboxReader().load_data('mbox_data_dir', max_count=1000) # Returns list of documents "
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "index = GPTSimpleVectorIndex.from_documents(documents) # Initialize index with documents"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": 4,
            "metadata": {},
            "outputs": [
                {
                    "name": "stdout",
                    "output_type": "stream",
                    "text": [
                        "> [query] Total LLM token usage: 100 tokens\n",
                        "> [query] Total embedding token usage: 10 tokens\n"
                    ]
                }
            ],
            "source": [
                "res = index.query('When did i have that call with the London office?')"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [
                {
                    "name": "stdout",
                    "output_type": "stream",
                    "text": [
                        "> There is a call scheduled with the London office at 12am GMT on the 10th of February."
                    ]
                }
            ],
            "source": [
                "res.response"
            ]
        }
    ],
    "metadata": {
        "kernelspec": {
            "display_name": ".venv",
            "language": "python",
            "name": "python3"
        },
        "language_info": {
            "codemirror_mode": {
                "name": "ipython",
                "version": 3
            },
            "file_extension": ".py",
            "mimetype": "text/x-python",
            "name": "python",
            "nbconvert_exporter": "python",
            "pygments_lexer": "ipython3",
            "version": "3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)]"
        },
        "orig_nbformat": 4,
        "vscode": {
            "interpreter": {
                "hash": "7dd9b00487715d9ffc85f7f860a0013e7a0542b27fc53d2b1d33405d7679eac1"
            }
        }
    },
    "nbformat": 4,
    "nbformat_minor": 2
}